function formDay(objDay) {
	var strDay = objDay.getFullYear().toString() + "-";
	strDay += ((objDay.getMonth()+1) < 10)?"0"+(objDay.getMonth()+1).toString() + "-":(objDay.getMonth()+1).toString() + "-";
	strDay += (objDay.getDate() < 10)?"0"+objDay.getDate().toString():objDay.getDate().toString(); 
	return strDay;
}

function getSunday(objDay) {
	var isGet = true;
	var objFisrtDay = new Date(objDay.getFullYear(), objDay.getMonth(), 1);
	if(objFisrtDay.getDay() == 1){
		objFisrtDay.setDate(objFisrtDay.getDate() - 1);
		return objFisrtDay;
	}
	while(isGet) {
		if (objFisrtDay.getDay() == 0) {
			if (objFisrtDay.getTime() >= objDay.getTime()) {
				objFisrtDay.setMonth(objFisrtDay.getMonth() - 1);
				objFisrtDay.setDate(1);
			}else{
				isGet = false;
			}
		}else{
			objFisrtDay.setDate(objFisrtDay.getDate()+1);
		}
	}
	return objFisrtDay;
}

function goDay(intType) {
	var strDay = "";
	switch (intType) {
		case 0:
			flag = 1;
			objTempToday = new Date(arrT[0], arrT[1] - 1, arrT[2]);
			objTempToday.setDate(objToday.getDate() + 1);
			break;
		case -1:
			flag = 1;
			objTempToday.setDate(objTempToday.getDate() - 1);
			break;
		case 1:
			if (flag == 0) {
				objTempToday.setDate(objTempToday.getDate() + 2);
				flag = 1;
			}else{
				objTempToday.setDate(objTempToday.getDate() + 1);
			}
			break;
	}
	strDay = formDay(objTempToday);
	setFormSearchDay(strDay, strDay);
}

function goLastWeek() {
	var objWToday = new Date(arrT[0], arrT[1] - 1, arrT[2]);
	var objSToday = new Date(arrT[0], arrT[1] - 1, arrT[2]);
	if (objWToday.getDay() != 0) {
		objWToday.setDate(objWToday.getDate() - objWToday.getDay() - 7 + 1);
		objSToday.setDate(objSToday.getDate() - objSToday.getDay() - 1 + 1);
	}else{
		objWToday.setDate(objWToday.getDate() - 14 + 1);
		objSToday.setDate(objSToday.getDate() - 8 + 1);
	}
	setFormSearchDay(formDay(objWToday), formDay(objSToday));
}

function goWeek() {
	var objWToday = new Date(arrT[0], arrT[1] - 1, arrT[2]);
	if (objWToday.getDay() != 0) {
		objWToday.setDate(objWToday.getDate() - objWToday.getDay() + 1);
	}else{
		objWToday.setDate(objWToday.getDate() - 7 + 1);
	}
	setFormSearchDay(formDay(objWToday), strToday);
}


function goMonth(intType) {
	switch (intType) {
		case 0:
			var objFisrtDay = new Date(objToday.getFullYear(), objToday.getMonth(), 1);
			var strEndDay = strToday;
			setFormSearchDay(formDay(objFisrtDay), strEndDay);
			break;
		case -1:
			var objFisrtDay = new Date(objToday.getFullYear(), objToday.getMonth() - 1, 1);
			var objEndDay = new Date(objToday.getFullYear(), objToday.getMonth(), 1);
			objEndDay.setDate(objEndDay.getDate() - 1)
			setFormSearchDay(formDay(objFisrtDay), formDay(objEndDay));
			break;
	}
}